import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * 查询跟物品有关的订单列表
 * @param query
 * @returns {*}
 */
export const listMenu = (query?: mallMenu): AxiosPromise<mallMenu[]> => {
  return request({
    url: '/mall/menu/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询跟物品有关的订单详细
 * @param id
 */
export const getMenu = (id: number): AxiosPromise<mallMenu> => {
  return request({
    url: '/mall/menu/' + id,
    method: 'get'
  });
};

/**
 * 新增跟物品有关的订单
 * @param data
 */
export const addMenu = (data: mallMenu) => {
  return request({
    url: '/mall/menu',
    method: 'post',
    data: data
  });
};

/**
 * 修改跟物品有关的订单
 * @param data
 */
export const updateMenu = (data: mallMenu) => {
  return request({
    url: '/mall/menu',
    method: 'put',
    data: data
  });
};

/**
 * 修改跟物品有关的订单
 * @param ids
 */
export const deleteMenu = (ids?: number[])=>{
  return request({
    url: '/mall/menu/' + ids,
    method: 'delete',
  })
}

export interface mallMenu extends BaseEntity, PageQuery {
  //菜单id
  id?: number;
  //菜单名称
  name?: string;
  //父菜单id
  parentId?: number;
  //产品Id
  sort?: number;
  //状态（0正常，1停用）
  status?: string;
  //pc端图标
  iconPc?: number;
  //手机端图标
  iconApp?: number;
  //手机端图标
  remark?: string;
  /*-------其他字段-------*/
  url?: string;
  children?: mallMenu[];
}
